﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="cart.aspx.cs" Inherits="HelloASPX.cart" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div class="container" style="background-color: white;">
	<div class="row" style="margin-left: 40px">
		<h3>我的购物车<br/><small style="display: block;width: 500px;height: 20px; font-size: 12px;margin-top: 10px;">温馨提示：产品是否购买成功，以最终下单为准哦，请尽快结算</small></h3>
	</div>
			                <asp:DataList ID="DataList1" runat="server" DataSourceID="XmlDataSource1">
                                <HeaderTemplate>
                                    <table class="table table-bordered table-striped table-hover">
 				                        <tr>
                                            <th>购物车号</th>
                                            <th>用户名</th>
 				                        	<th>商品号</th>
 				                        	<th>商品名称</th>
                                            <th>商品上架时间</th>
 				                        	<th>商品价格</th>
 				                        	<th>商品详情数量</th>
 				                        </tr>
                                    </table>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    productid:
                                    <asp:Label ID="productidLabel" runat="server" Text='<%# Eval("productid") %>' />
                                    <br />
                                    productname:
                                    <asp:Label ID="productnameLabel" runat="server" Text='<%# Eval("productname") %>' />
                                    <br />
                                    producttime:
                                    <asp:Label ID="producttimeLabel" runat="server" Text='<%# Eval("producttime") %>' />
                                    <br />
                                    productimage:
                                    <asp:Label ID="productimageLabel" runat="server" Text='<%# Eval("productimage") %>' />
                                    <br />
                                    productprice:
                                    <asp:Label ID="productpriceLabel" runat="server" Text='<%# Eval("productprice") %>' />
                                    <br />
                                    productinfo:
                                    <asp:Label ID="productinfoLabel" runat="server" Text='<%# Eval("productinfo") %>' />
                                    <br />
                                    <br />
                                </ItemTemplate>
            </asp:DataList>

	        <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/carts.xml" TransformFile="~/App_Data/carts.xslt" XPath="/carts/cart/product"></asp:XmlDataSource>

	<div class="row" style="margin-top: 40px;">
		<div class="col-md-10 col-md-offset-1">
			<table class="table table-bordered table-striped table-hover">
 				<tr>
 					<th>序号</th>
 					<th>商品名称</th>
 					<th>价格</th>
 					<th>数量</th>
 					<th>小计</th>
 					<th>操作</th>
 				</tr>
 				<c:forEach items="${list}" var="c" varStatus="i">
	 				<tr>
	 					<th>${i.count}</th>
	 					<th>${c.product.pname}</th>
	 					<th>${c.product.pprice}</th>
	 					<th width="100px">
		 					<div class="input-group">
		 						<span class="input-group-btn">
		 							<button class="btn btn-default" type="button" onclick="sub(${c.cid},${c.cnum},${c.product.pprice})">-</button>
		 						</span>
		 						<input type="text" class="form-control" id="num_count${i.count}" value="${c.cnum}" readonly="readonly" style="width:40px">
		 						<span class="input-group-btn">
		 							<button class="btn btn-default" type="button" onclick="add(${c.cid},${c.cnum},${c.product.pprice})">+</button>
		 						</span>
	 						</div>
	 					</th>
	 					<th>¥&nbsp;${c.ccount }</th>
	 					<th>
	 						<button type="button" class="btn btn-default" onclick="delCart(${c.cid})">删除</button>
	 					</th>
	 				</tr>
	 				<c:set var="sum" value="${sum+c.ccount}"></c:set>
 				</c:forEach>
			</table>
		</div>
	</div>
</div>
    </form>
</body>
</html>
